package in.srain.cube.request;

public interface IRequest<T, OriginT> {

    RequestData getRequestData();

    void onRequestSuccess(T data);

    void onRequestFail(Object requestTag, FailData failData);

    RequestBase setFailData(FailData failData);

    FailData getFailData();

    /**
     * send request
     */
    void send();

    /**
     * request synchronously
     */
    T requestSync() throws Throwable;

    void cancelRequest();

    T onDataFromServer(OriginT data);

    /**
     * filter the origin data or convert its structure.
     *
     * @param originData
     * @return
     */
    T processOriginDataFromServer(OriginT originData);

    /**
     * If it is true, should call {@link #onRequestSuccess} and {@link #onRequestFail} to main thread.
     * @return
     */
    boolean isPostToMainThread();
}